import Vue from 'vue';
import VueRouter from 'vue-router';
import routes from './routes.js';
// 要告诉 vue 使用 vueRouter
Vue.use(VueRouter);

// 路由配置
const RouterConfig = {
    mode: 'history',
    routes: routes,
	//自动回滚到top前面
	scrollBehavior: () => ({ y: 0 })
};


var router =  new VueRouter(RouterConfig)

/* 页面标题处理 */
router.afterEach(to=> {
  const title = to.meta.title
  if (title) {
    document.title = title
  }
  //window.scrollTo(0,0);
})

export default router;
